﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using The_Chronicles_of_Asku.Characters;
using The_Chronicles_of_Asku.Areas.Resources;

namespace The_Chronicles_of_Asku
{
    class Inn
    {
        public bool completeFirst = false;

        public void Greeting(Hero myHero)
        {
            if (completeFirst == false)
            {
                Console.WriteLine(InnText.InnFirstEntrance, myHero.Identifier);
                ClearScreen();
                completeFirst = true;
            }

            Console.WriteLine(InnText.ShopQuestion);
            Console.WriteLine();
            string answer = Console.ReadLine();

            if (answer == "1")
            {
                Console.WriteLine();
                Console.WriteLine(InnText.Gold, myHero.gold);
                Shop(myHero);
            }

            Console.WriteLine();
            Console.WriteLine(InnText.Goodbye);
            ClearScreen();
            
        }

        public void Shop(Hero myHero)
        {
            string shopAnswer;
            Console.WriteLine();
            bool shopDone = false;
            while (!shopDone)
            {
                Console.WriteLine(InnText.ShopInterface);
                shopAnswer = Console.ReadLine();
                Console.WriteLine();
                switch (shopAnswer)
                {
                    case "1":
                        if (myHero.gold >= 1000)
                        {
                            Console.WriteLine(InnText.FineWine);
                            myHero.gold = myHero.gold - 1000;
                            Console.WriteLine();
                            Console.WriteLine(InnText.GoldLeft, myHero.gold);
                            Console.WriteLine();
                        }
                        else
                        {
                            Console.WriteLine(InnText.NotEnoughMoney);
                        }
                        break;
                    case "2":
                        if (myHero.gold >= 500)
                        {
                            Console.WriteLine(InnText.DragonsAle);
                            myHero.gold = myHero.gold - 500;
                            Console.WriteLine();
                            Console.WriteLine(InnText.GoldLeft, myHero.gold);
                            Console.WriteLine();
                        }
                        else
                        {
                            Console.WriteLine(InnText.NotEnoughMoney);
                        }
                        break;
                    case "3":
                        if (myHero.gold >= 20)
                        {
                            Console.WriteLine(InnText.Bread);
                            Console.WriteLine();
                            myHero.gold = myHero.gold - 20;
                            Console.WriteLine(InnText.GoldLeft, myHero.gold);
                            Console.WriteLine();
                        }
                        else
                        {
                            Console.WriteLine(InnText.NotEnoughMoney);
                        }
                        break;
                    case "4":
                        if (myHero.gold >= 250)
                        {
                            Console.WriteLine(InnText.Chicken);
                            Console.WriteLine();
                            myHero.gold = myHero.gold - 250;
                            Console.WriteLine(InnText.GoldLeft, myHero.gold);
                            Console.WriteLine();
                        }
                        else
                        {
                            Console.WriteLine(InnText.NotEnoughMoney);
                            Console.WriteLine();
                        }
                        break;
                    case "5":
                        shopDone = true;
                        break;
                    default:
                        Console.WriteLine(InnText.Idiot);
                        Console.WriteLine();
                        break;
                }
            }

            Console.WriteLine();
            Console.Clear();
        }

        private void ClearScreen()
        {
            Console.ReadKey();
            Console.Clear();
        }
    }
}
